package com.book.controller;

import java.util.logging.Logger;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.book.domain.Writting;
import com.book.service.WrittingService;


@Controller
public class WrittingController {
	
	@Autowired
	private WrittingService writtingService;
	
	protected static Logger logger = Logger.getLogger("WrittingController");
	
	@RequestMapping(value="writting_date.do")
	public String allSelect_date(Model model){
		System.out.println("allSelect_date "+writtingService.allSelect_date());		
		model.addAttribute("allSelect_date", writtingService.allSelect_date());
		
		return "writtingAllList_date";
	}
	
	@RequestMapping(value="writtingReply.do")
	public String boardReply(HttpServletRequest request, Model model, Writting writting){
		System.out.println(request.getParameter("bcode"));
		writting.setbCode(request.getParameter("bcode"));
		System.out.println("boardReply "+writtingService.boardReply(writting));		
		model.addAttribute("boardReply", writtingService.boardReply(writting));
		
		return "writtingAllListReply";
	}
	@RequestMapping(value="writtingSympathy.do")
	public String boardSympathy(HttpServletRequest request, Model model, Writting writting){
		System.out.println(request.getParameter("bcode"));
		writting.setbCode(request.getParameter("bcode"));
		System.out.println("boardSympathy "+writtingService.boardSympathy(writting));		
		model.addAttribute("boardSympathy", writtingService.boardSympathy(writting));
		
		return "writtingAllListSympathy";
	}
	
	
	@RequestMapping(value="writting_best.do")
	public String allSelect_best(HttpServletRequest request, Model model, Writting writting){
		System.out.println(request.getParameter("bbooktitle"));
		//writting.setbBookTitle(request.getParameter("bbooktitle"));
		System.out.println(request.getParameter("bbookurl"));
		writting.setbBookUrl(request.getParameter("bbookurl"));
		System.out.println("allSelect_best "+writtingService.allSelect_best(writting));		
		model.addAttribute("allSelect_best", writtingService.allSelect_best(writting));
		
		return "writtingAllList_best"; 
	}
	
	@RequestMapping(value="writting_sympathy.do")
	public String allSelect_sympathy(Model model){
		System.out.println("allSelect_sympathy "+writtingService.allSelect_sympathy());		
		model.addAttribute("allSelect_sympathy", writtingService.allSelect_sympathy());
		
		return "writtingAllList_sympathy";
	}
	
	
	@RequestMapping(value="writting_follow.do")
	public String allSelect_follow(HttpServletRequest request, Model model, Writting writting){
		System.out.println(request.getParameter("mcode"));
		writting.setmCode(request.getParameter("mcode"));
		System.out.println("allSelect_follow "+writtingService.allSelect_follow(writting));		
		model.addAttribute("allSelect_follow", writtingService.allSelect_follow(writting));
		
		return "writtingAllList_follow";
	}
	
	
}